Package org.python.pydev.editor.hover

Source Code of org.python.pydev.editor.hover.PyAnnotationHover

/**
* Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Eclipse Public License (EPL).
* Please see the license.txt included with this distribution for details.
* Any modifications to this file must keep this entire header intact.
*/
/*
* Created on 02/08/2005
*
* @author Fabio Zadrozny
*/
package org.python.pydev.editor.hover;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.python.pydev.core.log.Log;
import org.python.pydev.editor.codefolding.MarkerAnnotationAndPosition;
import org.python.pydev.editor.codefolding.PySourceViewer;

import com.aptana.shared_core.string.FastStringBuffer;

public class PyAnnotationHover implements IAnnotationHover {

    public PyAnnotationHover(ISourceViewer sourceViewer) {
    }

    public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
        FastStringBuffer buf = new FastStringBuffer();

        if (sourceViewer instanceof PySourceViewer) {
            PySourceViewer s = (PySourceViewer) sourceViewer;

            for (MarkerAnnotationAndPosition marker : s.getMarkersAtLine(lineNumber, null)) {
                try {
                    if (buf.length() > 0) {
                        buf.append("\n");
                    }
                    buf.appendObject(marker.markerAnnotation.getMarker().getAttribute(IMarker.MESSAGE));
                } catch (CoreException e) {
                    Log.log(e);
                }
            }

        }
        return buf.toString();
    }

}
TOP

Related Classes of org.python.pydev.editor.hover.PyAnnotationHover

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.